# Rules.log  -*- Makefile -*-
# Copyright 2005 Lyra LLC, All rights reserved.
#
# Allows the user to customize the Makefile's log behaviour 


# Set the log files
LOG_FILE_COMPILE  := compile.log
LOG_FILE_LINK     := link.log
LOG_FILE_MAKE     := make.log


# Set the log method (redirect, copy or none)
# LOG_METHOD := LOG_REDIRECT
 LOG_METHOD := LOG_COPY
# LOG_METHOD := LOG_NONE


# Define CPP Log Macros
ifneq ($(LOG_METHOD), LOG_NONE)

	# CPP Header
	define LOG_CPP_HEADER
		@$(ECHO) -e "--------------------------------------------------------------------------------\n" >> $(LOG_FILE_COMPILE); \
		 $(ECHO) -e " *** $< *** \n\n"                                                                   >> $(LOG_FILE_COMPILE); \
		 $(ECHO) -e "  [$(CXX) $(CPLUSFLAGS) -c $< -o $@]\n\n"                                           >> $(LOG_FILE_COMPILE);
        endef

	# CPP Footer
	define LOG_CPP_FOOTER
		@$(ECHO) -e "\n\n *** $< *** \n"                                                                 >> $(LOG_FILE_COMPILE); \
		 $(ECHO) -e "--------------------------------------------------------------------------------\n" >> $(LOG_FILE_COMPILE);
        endef

endif

#
# Redirect ALL output to the log files
#
ifeq ($(LOG_METHOD), LOG_REDIRECT)

	LOG_COMPILE := >> $(LOG_FILE_COMPILE) 2>&1
	LOG_LINK    := >> $(LOG_FILE_LINK)    2>&1
	LOG_MAKE    := >> $(LOG_FILE_MAKE)    2>&1

endif


#
# Copy ALL output to the log files
#
ifeq ($(LOG_METHOD), LOG_COPY)

	LOG_COMPILE := 2>&1| $(TEE) -a $(LOG_FILE_COMPILE)
	LOG_LINK    := 2>&1| $(TEE) -a $(LOG_FILE_LINK)
	LOG_MAKE    := 2>&1| $(TEE) -a $(LOG_FILE_MAKE)

endif


#
# Don't use logs at all
#
ifeq ($(LOG_METHOD), LOG_NONE)

	define LOG_CPP_HEADER
		@$(ECHO) -e "  [$(CXX) $(CPLUSFLAGS) -c $< -o $@]\n\n";
        endef

	define LOG_CPP_FOOTER
        endef

	LOG_COMPILE  :=
	LOG_LINK     :=
	LOG_MAKE     :=

endif
